<?php
/**
 * Created by PhpStorm.
 * User: TS
 * Date: 2017/4/4
 * Time: 20:25
 */
namespace core;

use Predis\Client;

class Cache {

    protected static $instance;

    protected $redis;

    /**
     * Cache constructor.
     * @param array $options
     */
    public function __construct(array $options = [])
    {
        $this->redis = new Client($options);
    }

    /**
     * @param array $options
     * @return static
     */
    public static function getInstance($options = [])
    {
        if (!isset(self::$instance)) {
            self::$instance = new static($options);
        }
        return self::$instance;
    }

    /**
     * @param $name
     * @param $arguments
     * @return mixed
     */
    public function __call($name, $arguments)
    {
        return call_user_func_array(array($this->redis, $name), $arguments);
    }
}